package paperless.main;

import java.util.ArrayList;

import paperless.information.InformationTabActivity;
import paperless.setting.SettingMain;

import android.app.AlertDialog;
import android.app.Fragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

import com.example.paperless.R;

public class MainBottomFragment extends Fragment {

	private ArrayList<Integer> listCoupon;
	private GridView couponView;
	private MyAdapter mAdapter;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.main_bottom_fragment, container,false);
		prepareList();

		couponView = (GridView) v.findViewById(R.id.gridview1);
		mAdapter = new MyAdapter(getActivity(), listCoupon);
		couponView.setAdapter(mAdapter);

		couponView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				switch (position) {
				case 9:
					CustomDialog dialog = new CustomDialog(getActivity());

					dialog.show();
					break;
				default:
					Intent i = new Intent(getActivity(),
							InformationTabActivity.class);
					startActivity(i);
					break;
				}

			}
		});
		return v;
	}

	public void prepareList() {
		listCoupon = new ArrayList<Integer>();
		for (int i = 0; i < 9; i++)
			listCoupon.add(R.drawable.no_coupon);
		listCoupon.add(R.drawable.ok_coupon);

	}

}
